﻿using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using DefCore.Mapping;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DefCore.Tools;

namespace DefCore
{
    public sealed class StructureBin
    {
        //Singleton Pattern
        private static StructureBin _Instance;
        public static StructureBin Instance
        {
            get
            {
                if (_Instance == null)
                    _Instance = new StructureBin();

                return _Instance;
            }
        }
        
        //Methods
        private Dictionary<string, Texture2D> _StructureBank;
        
        //cTor
        protected StructureBin()
        {
            _StructureBank = new Dictionary<string, Texture2D>();
        }

        //Methods
        public Texture2D GetStructure(string strName, bool blueprint)
        {
            if (blueprint)
                return _StructureBank[string.Format("{0}_{1}", strName, "BLUEPRINT")];
            else
                return _StructureBank[strName];
        }

        public void Load()
        {
            _StructureBank.Add("LANTERN", SpriteSheetHelper.Retreive(ResourceBin.Instance.Get<Texture2D>("STRUCT_LANTERN"), new Rectangle(0, 0, 66, 66)));
            _StructureBank.Add("LANTERN_BLUEPRINT", SpriteSheetHelper.Retreive(ResourceBin.Instance.Get<Texture2D>("STRUCT_LANTERN"), new Rectangle(66, 0, 66, 66)));

            _StructureBank.Add("BRIDGE_WOOD", SpriteSheetHelper.Retreive(ResourceBin.Instance.Get<Texture2D>("STRUCT_WOODBRIDGE"), new Rectangle(0, 0, 184, 184)));
            _StructureBank.Add("BRIDGE_WOOD_BLUEPRINT", SpriteSheetHelper.Retreive(ResourceBin.Instance.Get<Texture2D>("STRUCT_WOODBRIDGE"), new Rectangle(184, 0, 184, 184)));
        }
    }
    
}
